﻿<?php
	$db_config["hostname"] = "localhost"; //服务器地址
	$db_config["username"] = "root"; //数据库用户名
	$db_config["password"] = "91zhan"; //数据库密码
	$db_config["database"] = "meisheng2013"; //数据库名称
	$db_config["charset"] = "utf8";//数据库编码
	$db_config["pconnect"] = "conn";//开启持久连接
require_once("../../../libs/string/libstr.php");
require_once("../../../libs/dbclass/dbconn.php");

$mc=new libstr();
$db=new dbconn($db_config["hostname"],$db_config["username"],$db_config["password"], $db_config["database"],$db_config["pconnect"],$db_config["charset"]);



$tt=$db->ds("select id,name,count from college");
$data=array();
for($i=0;$i<count($tt);$i++){
$data[]=array($tt[$i]["name"],intval($tt[$i]["count"]))	;
}
$data = json_encode($data); 

//print_r($data);

//
//echo($sv->mappath("product_class",1,"所有","kk.php,jkl.php,kiu.php",true));
//echo dirname(__FILE__)."/../../libs/dbclass/dbconn.php";

?>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Highcharts Example</title>

		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
		<script type="text/javascript">
$(function () {
    	
    	// Radialize the colors
		Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) {
		    return {
		        radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
		        stops: [
		            [0, color],
		            [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
		        ]
		    };
		});
		
		// Build the chart
        $('#container').highcharts({
            chart: {
                plotBackgroundColor: null,//设置图表的一些样式
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: '电白一中高三（36）班报考情况'//标题
            },
            tooltip: {
        	   formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ this.percentage.toFixed(2) +' %';//格式化数据
                        }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,//允许选中，点击选中的扇形区可以分离出来显示
                    cursor: 'pointer',//当鼠标指向扇形区时变为手型（可点击） 
                    dataLabels: {
                        enabled: true,//设置数据标签可见，即显示每个扇形区对应的数据 
                        color: '#000000',//数据显示颜色 
                        connectorColor: '#000000',//设置数据域扇形区的连接线的颜色 
                        formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ this.percentage.toFixed(2) +' %';//格式化数据
                        }
                    }
                }
            },
            series: [{//数据列
                type: 'pie',
                name: 'Browser share',
                data:<?php echo $data;?> //这个是json数组
            }]
        });
    });
    

		</script>
	</head>
	<body>
<script src="../../js/highcharts.js"></script>
<script src="../../js/modules/exporting.js"></script>

<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

	</body>
</html>

 
